﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.ApplicationSettings;
using Crystalbyte.Equinox.Imap;
using System.Collections.ObjectModel;
using System.Diagnostics;
using Windows.Storage;

namespace Application4
{
    partial class MainPage
    {
        public MainPage()
        {
            InitializeComponent();
            RightTapped += new Windows.UI.Xaml.Input.RightTappedEventHandler(MainPage_RightTapped);
        }

        private void SaveSettings(
          object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            setting.Username = UsernameForm.Text;
            setting.Password = PasswordForm.Password;
        }

        void MainPage_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedEventArgs e)
        {
            Windows.UI.Xaml.GridLength h = (Windows.UI.Xaml.GridLength)LayoutRoot.RowDefinitions.First().GetValue(RowDefinition.HeightProperty);
            if (h.Value == 0)
            {
                h.Value = 100;
            }
            else
            {
                h.Value = 0;
            }
            LayoutRoot.RowDefinitions.First().SetValue(RowDefinition.HeightProperty, h);
        }

        private Setting _setting;
        public Setting setting
        {
            get { return _setting; }
            set
            {
                _setting = value;
                Setting.DataContext = _setting;
            }
        }
        void _mails_VectorChanged(IObservableVector<Envelope> sender, IVectorChangedEventArgs e)
        {
            Debug.WriteLine("got event");
        }

        private ObservableVector<object> _mails;
        public ObservableVector<object> mails
        {
            get { return _mails; }
            set
            {
                _mails = value;
                ItemListView.ItemsSource = _mails;
            }
        }
    }
}
